package com.terrace.web.tagext.easyui.model;

import java.io.Serializable;

import com.terrace.web.constant.IconConstant;
import com.terrace.web.tagext.easyui.GridConfirmOptTag;
import com.terrace.web.tagext.easyui.GridDeleteOptTag;
import com.terrace.web.tagext.easyui.GridFuncOptTag;
import com.terrace.web.tagext.easyui.GridOpenOptTag;
import com.terrace.web.tagext.easyui.GridUrlOptTag;

/**
 * 表格操作
 * 
 * @author jiangyg
 *
 */
public class GridOpt implements Serializable {

	private static final long serialVersionUID = 2922332856785261448L;

	/**
	 * 链接地址
	 */
	private String url;

	/**
	 * 操作标题
	 */
	private String title;

	/**
	 * 弹出窗宽度
	 */
	private String width;

	/**
	 * 弹出窗高度
	 */
	private String height;

	/**
	 * 删除消息
	 */
	private String message;

	/**
	 * 自定义函数名称
	 */
	private String funname;
	
	/**
	 * tab的iconCls
	 */
	private String iconCls;
	
	/**
	 * 权限编码
	 */
	private String permiCode;

	/**
	 * 表格操作类型
	 */
	private GridOptType optType;

	public GridOpt() {
		super();
	}
	
	public GridOpt(GridDeleteOptTag delOpt) {
		this.url = delOpt.getUrl();
		this.title = delOpt.getTitle();
		this.message = delOpt.getMessage();
		this.permiCode = delOpt.getPermiCode();
		this.optType = GridOptType.DELETE;
	}
	
	public GridOpt(GridUrlOptTag urlOpt) {
		this.url = urlOpt.getUrl();
		this.title = urlOpt.getTitle();
		this.permiCode = urlOpt.getPermiCode();
		this.optType = GridOptType.URL;
	}
	
	public GridOpt(GridOpenOptTag openOpt) {
		this.url = openOpt.getUrl();
		this.title = openOpt.getTitle();
		this.width = openOpt.getWidth();
		this.height = openOpt.getHeight();
		this.iconCls = IconConstant.obtainIconClass(openOpt.getIconCls());
		this.permiCode = openOpt.getPermiCode();
		if ("dialog".equals(openOpt.getOpenModel())) {
			this.optType = GridOptType.DIALOG;
		} else if ("tab".equals(openOpt.getOpenModel())) {
			this.optType = GridOptType.TAB;
		} else {
			this.optType = GridOptType.DIALOG;
		}
	}
	
	public GridOpt(GridFuncOptTag funcOpt) {
		this.url = funcOpt.getUrl();
		this.title = funcOpt.getTitle();
		this.funname = funcOpt.getFunname();
		this.permiCode = funcOpt.getPermiCode();
		this.optType = GridOptType.FUNC;
	}
	
	public GridOpt(GridConfirmOptTag confirmOpt) {
		this.url = confirmOpt.getUrl();
		this.title = confirmOpt.getTitle();
		this.message = confirmOpt.getMessage();
		this.permiCode = confirmOpt.getPermiCode();
		this.optType = GridOptType.CONFIRM;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getWidth() {
		return width;
	}

	public void setWidth(String width) {
		this.width = width;
	}

	public String getHeight() {
		return height;
	}

	public void setHeight(String height) {
		this.height = height;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getFunname() {
		return funname;
	}

	public void setFunname(String funname) {
		this.funname = funname;
	}

	public String getIconCls() {
		return iconCls;
	}

	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

	public String getPermiCode() {
		return permiCode;
	}

	public void setPermiCode(String permiCode) {
		this.permiCode = permiCode;
	}

	public GridOptType getOptType() {
		return optType;
	}

	public void setOptType(GridOptType optType) {
		this.optType = optType;
	}

}
